class Solution(object):
    def widestPairOfIndices(self, nums1, nums2):
        pre = {0: -1}
        n = len(nums1)
        now = 0
        max_val = 0
        for i in range(n):
            now += nums1[i] - nums2[i]
            if now in pre:
                max_val = max(max_val, i - pre[now])
            else:
                pre[now] = i
        return max_val
